package com.briup.mt.service.impl;

import com.briup.mt.bean.*;
import com.briup.mt.dao.BasePrivilegeMapper;
import com.briup.mt.service.IBasePrivilegeService;
import org.apache.poi.ss.formula.eval.UnaryMinusEval;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * @version 1.0
 * @auther zy
 * @date 2020/12/16 22:32
 */

@Service
public class BasePrivilegeServiceImpl implements IBasePrivilegeService {
    @Resource
    private BasePrivilegeMapper basePrivilegeMapper;


@Override
    public List<BasePrivilege> query(String name) {
        BasePrivilegeExample example=new BasePrivilegeExample();
    if(!StringUtils.isEmpty(name)){
        example.createCriteria().andNameLike("%" + name + "%");
    }
        return basePrivilegeMapper.selectByExample(example);
    }




    @Override
    public void saveOrUpdate(BasePrivilege basePrivilege) {
        if (basePrivilege.getId() == null) {
            basePrivilegeMapper.insert(basePrivilege);
        }else{
            basePrivilegeMapper.updateByPrimaryKey(basePrivilege);
        }
    }

    @Override
    public void deleteById(long id) {
        basePrivilegeMapper.deleteByPrimaryKey(id);
    }
}
